﻿@{
    ViewBag.Title = "产品归类";
    Layout = "~/Areas/Admin/Views/Shared/_InfoLayout.cshtml";
}
<script type="text/javascript">
    $(function(){
        $("#ddlRootCategoryFrom").change(function(){ 
            var selec = $(this).val();  //获取改变的选项值
            var url = "@Url.Action("QY")";  //参数依次类型(action,Controller,area）
            $("#ItemDeitalIDFrom").find("option").remove();  //清空
            $.getJSON(url, { 'ParentID': selec }, function (data) {  
                $.each(data, function (i, item) {
                    $("<option></option>").val(item["Value"]).text(item["Text"]).appendTo($("#ItemDeitalIDFrom"));
                });  
            });     
        });

        $("#ddlRootCategoryTo").change(function(){ 
            var selec = $(this).val();  //获取改变的选项值
            var url = "@Url.Action("QY")";  //参数依次类型(action,Controller,area）
            $("#ItemDeitalIDTo").find("option").remove();  //清空
            $.getJSON(url, { 'ParentID': selec }, function (data) {  
                $.each(data, function (i, item) {
                    $("<option></option>").val(item["Value"]).text(item["Text"]).appendTo($("#ItemDeitalIDTo"));
                });  
            });     
        });
    });
</script>
<div id="main">
    @using (Html.BeginForm("CategoryMove", "Info", FormMethod.Post))
    {
        @Html.ValidationSummary(true)
        <fieldset>
            <div class="field">
                <div class="editor-label">
                    来源类别：
                </div>
                <div class="editor-field" style="width:auto; margin-right:10px;">
                    @Html.DropDownList("ddlRootCategoryFrom", (SelectList)ViewBag.rootCategoryList, "请选择类别")
                </div>
                <div class="editor-field" style="width:auto; margin-right:10px;">
                    @Html.DropDownList("ItemDeitalIDFrom", (IEnumerable<SelectListItem>)ViewBag.CategoryList)
                </div>
            </div>
            <div class="field">
                <div class="editor-label">
                    归入类别：
                </div>
                <div class="editor-field" style="width:auto; margin-right:10px;">
                    @Html.DropDownList("ddlRootCategoryTo", (SelectList)ViewBag.rootCategoryList, "请选择类别")
                </div>
                <div class="editor-field" style="width:auto; margin-right:10px;">
                    @Html.DropDownList("ItemDeitalIDTo", (IEnumerable<SelectListItem>)ViewBag.CategoryList)
                </div>
            </div>
            <div class="field">
            <input type="submit"  value="确定归入" />
            @if (ViewBag.count != null) { 
                <p>已成功归入 @ViewBag.count 条数据！</p>
            }
            </div>
        </fieldset>
    }
</div>
